//
//  BBNodeController.h
//  xNose
//
//  Created by ben smith on 9/7/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>

// the node controller holds all the currently active nodes

@class BBNode;
@class BBLeafNodeView;
@class BBNodeView;
@class BBZoomView;

// this object does much of the heavy lifting for keeping the node tree in order and the views stacked properly
// it should probably be split into two objects; one for node tree and one for view handling

@interface BBNodeController : NSObject {
	BBNode * rootNode;
	IBOutlet NSView * rootView;
	NSView * currentRootView;
	BBNode * connectionSource;	
	NSInteger editingCount;
	NSTextField * bogus;
	NSView * underlayView;
	NSView * overlayView;
	NSView * dimmingView;
	NSView * grandTotalView;
	BBZoomView * zoomView;
	NSView * toolTabView;
	NSView * blobDrawView;
	NSView * fileTabView;
	BOOL isActive;
	BOOL isDraggingNode;
	BOOL isZoomed;
	NSPoint nodeSnapPoint;
	NSRect zoomFrame;
	float scale;
}

@property (assign) NSPoint nodeSnapPoint;
@property (assign) float scale;
@property (retain) BBNode * rootNode;
@property (retain) 	NSView * currentRootView;
@property (retain) 	NSView * underlayView;
@property (retain) 	NSView * blobDrawView;
@property (retain) 	NSView * dimmingView;
@property (retain) BBNode * connectionSource;

-(NSRect)trashRect;

-(void)setActive:(BOOL)b;
+ (BBNode*)rootNode;
+ (BBNodeController*)sharedNodeController;
- (BOOL)isActive;
- (BOOL)isDraggingNode;
- (IBAction)refreshView:(id)sender;
- (NSView*)hitTest:(NSPoint)p
;
- (NSView*)hitTest:(NSPoint)p forNode:(BBNode*)aNode;
- (void)addDimLayer;
- (void)addNode:(BBNode*)aNode nextTo:(BBNode*)existingNode above:(BOOL)above;
- (void)awakeFromNib;
- (void)checkScrollPoint:(BBNode*)aNode;
- (void)clearActive;
- (void)collapseNode:(BBNode*)aNode;
- (void)endNodeDrag;
- (void)enterFullscreen;
- (void)exitFullscreen;
- (void)expandConnectedNodes:(BBNode*)aNode;
- (void)expandNode:(BBNode*)aNode;
- (void)finishZoom;
- (void)loadViewInto:(NSView*)aView;
- (void)makeDefaultNodeTree ;
- (void)mouseDraggedDuringDrag:(NSEvent*)theEvent;
- (void)mouseUpDuringDrag:(NSEvent*)theEvent;
- (void)moveNode:(BBNode*)aNode nextTo:(BBNode*)existingNode above:(BOOL)above;
- (void)newTree;
- (void)registerConnectionSource:(BBNode*)aNode;
- (void)releaseEdit:(id)sender;
- (void)removeDimLayer;
- (void)removeNode:(BBNode*)aNode;
- (void)resetAllNodes;
- (void)resetTopLayers;
- (void)scrollAllNodes:(float)xShift animate:(BOOL)animate;
- (void)setNodeScrollPoint:(float)xShift animate:(BOOL)animate;
- (void)startDragging:(NSImage*)image node:(BBNode*)aNode from:(NSPoint)p;
- (void)startEditNotification:(id)sender;
- (void)startNodeDrag;
- (void)stopEditNotification:(id)sender;
- (void)zoomNotification:(NSNotification*)note;
-(void)scrollAllNodesX:(float)xShift y:(float)yShift animate:(BOOL)animate;
// 38 methods

@end
